/**
 * @file	halPeripheral.c
 * @author	chipsea
 * @brief	
 * @version	0.1
 * @date	2020-11-30
 * @copyright Copyright (c) 2020, CHIPSEA Co., Ltd.
 * @note
 */

/*********************************************************************
 * INCLUDES
 */
#include "log.h"
#include "key.h"
#include "OSAL.h"
#include "gpio.h"
#include "clock.h"
#include "error.h"
#include "pwrmgr.h"
#include "rom_sym_def.h"
#include "global_config.h"
#include "halPeripheral.h"
#include	"watchdog.h"
uint8 Hal_TaskID;

/**
 * @fn      void sample_wdt_init( void )
 * @brief   watchdog initialization
 * @param   none
 * @return  none
 */
void sample_wdt_init( void )
{
	HalWdtInit(ENABLE, WDG_USE_POLLING_MODE, NULL);
	LOG("WDT Init\r\n");
}
	


/**
 * @fn      void HalPeripheral_Init(uint8 task_id)
 * @brief   Peripheral initialization
 * @param   task_id
 * @return  none
 */
void HalPeripheral_Init(uint8 task_id)
{
	Hal_TaskID = task_id;
	
	sample_wdt_init();
	osal_set_event( Hal_TaskID, USR_TEST_TIMER1_EVT );
}

/**
 * @fn      uint16 HalPeripheral_ProcessEvent( uint8 task_id, uint16 events )
 * @brief   Peripheral event process
 * @param   task_id
 * @param	events
 * @return  none
 */
uint16 HalPeripheral_ProcessEvent( uint8 task_id, uint16 events )
{
	if(task_id != Hal_TaskID)
    {
		return 0;
	}
	
	if( events & USR_TEST_TIMER1_EVT )
    {
		HalWdtFeed();
        osal_start_timerEx( Hal_TaskID, USR_TEST_TIMER1_EVT, 3000);
        return ( events ^ USR_TEST_TIMER1_EVT );
    }
	
	
    return 0;
}

/*********************************************************************
*********************************************************************/
